package com.platform.modular.controller;

import com.platform.common.model.Result;
import com.platform.modular.feign.order.ActivityOrderFeignService;
import com.platform.modular.model.order.ActivityOrderDetail;
import com.platform.modular.model.order.ActivityOrderListDTO;
import com.platform.modular.model.order.SignUpActivityDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author yifei.han
 * @version 1.0
 * @className ActivityOrderController
 * @description 活动订单控制层
 * @date 2022/3/18
 */
@Slf4j
@RestController
@RequestMapping("miniprogram/activityorder")
public class ActivityOrderController {

    @Autowired
    private ActivityOrderFeignService activityOrderFeignService;

    /**
     * 报名活动
     * @param signUpActivityDTO
     * @return
     */
    @RequestMapping(value = "/signUpActivity")
    public Result<Map<String, Object>> signUpActivity(@RequestBody SignUpActivityDTO signUpActivityDTO) {
        return activityOrderFeignService.signUpActivity(signUpActivityDTO);
    }

    /**
     * 活动订单列表
     * @param activityOrderListDTO
     * @return
     */
    @RequestMapping(value = "/activityOrderList")
    public Result activityOrderList(ActivityOrderListDTO activityOrderListDTO) {
        List<ActivityOrderDetail> activityOrderList = activityOrderFeignService.queryActivityOrderList(activityOrderListDTO);
        return Result.ok().setResult(activityOrderList);
    }

    /**
     * 活动订单详情
     * @param activityOrderId
     * @return
     */
    @RequestMapping(value = "/activityOrderDetail")
    public Result activityOrderDetail(@RequestBody Long activityOrderId) {
        ActivityOrderDetail activityOrderDetail = activityOrderFeignService.obtainActivityOrderDetail(activityOrderId);
        return Result.ok().setResult(activityOrderDetail);
    }

    /**
     * 取消订单
     * @param activityOrderId
     * @return
     */
    @RequestMapping(value = "/cancelActivityOrder")
    public Result cancelActivityOrder(@RequestBody Long activityOrderId) {
        return activityOrderFeignService.cancelActivityOrder(activityOrderId);
    }




}
